<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<jsp:include page="../pageheader.jsp"/>

<div class="container">
    <div id="emailsSucessArea">
    </div>
    <div id="topicsDiv" class="list-group">
        <c:if test="${emails != null}">
            <c:forEach items="${emails}" var="email">
                <a class="list-group-item">
                    <div class="row">
                        <div class="col-xs-9">
                            <h4 class="list-group-item-heading">${email.getTopic()}</h4>
                        </div>
                        <div class="col-xs-3">
                            ${email.getSentDate()}
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-12">
                            <p class="list-group-item-text">${email.getMessage()}</p>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-12">
                            ${email.getSentUser().getName()}
                        </div>
                    </div>
                </a>
            </c:forEach>
        </c:if>
    </div>

    <form class="form-horizontal">
        <div class="form-group">
            <label for="usersDropDown" class="col-xs-12 col-sm-2">To</label>
            <div class="col-xs-12 col-sm-10">
                <select class="form-control" id="usersDropDown">
                    <option value="-1">Select a user</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="topicTitleField" class="col-xs-12 col-sm-2">Topic</label>
            <div class="col-xs-12 col-sm-10">
                <input type="text" class="form-control" maxlength="100" id="topicTitleField" placeholder="Topic..." />
            </div>
        </div>
        <div class="form-group ">
            <label for="topicMessageField" class="col-xs-12 col-sm-2">Message</label>
            <div class="col-xs-12 col-sm-10">
                <textarea class="form-control input-sm" maxlength="700" id="topicMessageField" placeholder="Message..."></textarea>
            </div>
        </div>
        <div class="form-group">
            <div class="col-xs-12">
                <button id="sendEmailButton" type="button" onclick="addNewEmailClick()" class="btn btn-primary">Send email</button>
            </div>
        </div>
    </form>
</div>

<jsp:include page="../pagefooter.jsp"/>
